package com.gtanyin.demo.televisionplus

import android.annotation.SuppressLint
import android.content.pm.ActivityInfo
import android.graphics.drawable.GradientDrawable
import android.net.Uri
import com.qzb.common.base.BaseActivity
import com.shuyu.gsyvideoplayer.utils.OrientationUtils
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer
import kotlinx.android.synthetic.main.activity_play.*

/**
 * author:tangyin
 * on:2018/1/24.
 * email:gtanyin@126.com
 */
class PlayActivity : BaseActivity<Contract.Presenter, Contract.Model>() {

    private lateinit var url: String
    private lateinit var title: String
    private lateinit var orientationUtil: OrientationUtils

    override fun getLayoutId(): Int = R.layout.activity_play

    override fun initPresenter() {
    }

    override fun initView() {

        orientationUtil= OrientationUtils(this, this.player)

        title = intent.getStringExtra("title")
        url = intent.getStringExtra("url")

        player.setUp(url,false,title)

        player.backButton.setOnClickListener { finish() }
        player.fullscreenButton.setOnClickListener { orientationUtil.resolveByClick() }
    }

    @SuppressLint("MissingSuperCall")
    override fun onPause() {
        player.onVideoPause()
        super.onPause()
    }

    @SuppressLint("MissingSuperCall")
    override fun onResume() {
        player.onVideoResume()
        super.onResume()
    }

    override fun onDestroy() {
        player.release()
        super.onDestroy()
    }
}